package com.lcredu.dao.impl;

import com.lcredu.dao.BasicDAO;
import com.lcredu.dao.OrderDAO;
import com.lcredu.entity.Order;

/**
 * @author 黎长容
 * @date 2025-07-09 11:11
 */
public class OrderDAOImpl extends BasicDAO<Order> implements OrderDAO {
    @Override
    public int savaOrder(Order order) {
        String saveSql = " INSERT INTO `order`(`id`,`create_time`,`price`,`status`,`member_id`)VALUES(?,?,?,?,?)";
        int updated = update(saveSql, order.getId(), order.getCreateTime(), order.getPrice(), order.getStatus(), order.getMemberId());
        return updated;
    }

    @Override
    public Order getOrderById(String orderId) {
        //select id, name, img_path AS imgPath, maker, price, sales, stock from furn where id = ?
        String sql = "SELECT id, create_time AS createTime, price, status, member_id AS memberId FROM `order` WHERE id = ?";
        Order order = querySingle(sql, Order.class, orderId);
        System.out.println("order=" + order);
        return order;
    }
}
